import {baseUrl} from '@/config/env';
import startSearchModel from "@/config/startSearchModel";
import startDurationTools from "utils/startDurationTools";

export default () => {
    return {
        index: true,
        submitText: '修改',
        size: 'default',
        labelWidth: 120,
        menuType: 'text',
        menuAlign: 'center',
        align: "center",
        menuPosition: "right",
        addBtn: false,
        delBtn: false,
        editBtn: false,
        searchIndex: 2,
        searchMenuSpan: 6,
        searchIcon: true,
        viewBtn: true,
        column: [
            {
                label: '流程名称',
                prop: 'procDefName',
                span: 12,
                search: true,
                searchModel: startSearchModel.LIKE_RIGHT,
                rules: [{
                    required: true,
                    trigger: "blur"
                }]
            },
            {
                label: '申请人',
                span: 12,
                prop: 'actStartUser',
                type: "input",
                bind: "actStartUser.userFinalName"
            },
            {
                search: true,
                type: "select",
                label: '审批状态',
                prop: 'procHandlerState',
                span: 12,
                dicMethod: "get",
                dicUrl: `${baseUrl}/start/sysDictionaryItem/listByDictionaryCode`,
                dicQuery: {dictCode: "procHandlerStatus"},
                props: {
                    label: 'dictName',
                    value: 'dictVal',
                },
                tag: true,
                dicFormatter: (res) => {
                    let data = res.data || []
                    for (let i = 0; i < data.length; i++) {
                        if (data[i].dictVal === null || data[i].dictVal === undefined) {
                            continue
                        }
                        data[i].dictVal = parseInt(data[i].dictVal);
                    }
                    return data
                },
                detail: true,
            },
            {
                label: '申请时间',
                prop: 'procStartTime',
                span: 12,
                type: 'datetime',
                valueFormat: 'YYYY-MM-DD HH:mm:ss',
                format: 'YYYY-MM-DD HH:mm:ss',
                editDisplay: false,
                addDisplay: false
            },
            {
                label: '节点',
                prop: 'taskDefName',
                span: 12,
                type: 'input',
                editDisplay: false,
                addDisplay: false
            },
            {
                label: '办理人',
                prop: 'assigneeNickName',
                span: 12,
                type: 'input',
                editDisplay: false,
                addDisplay: false
            },
            {
                label: '接收时间',
                prop: 'taskStartTime',
                type: 'datetime',
                span: 12,
                valueFormat: 'YYYY-MM-DD HH:mm:ss',
                format: 'YYYY-MM-DD HH:mm:ss',
                editDisplay: false,
                addDisplay: false
            },
            {
                label: '办理时间',
                prop: 'taskEndTime',
                type: 'datetime',
                span: 12,
                valueFormat: 'YYYY-MM-DD HH:mm:ss',
                format: 'YYYY-MM-DD HH:mm:ss',
                editDisplay: false,
                addDisplay: false
            },
            {
                label: '耗时',
                prop: 'taskDuration',
                span: 12,
                formatter: (row, value, column) => {
                    return startDurationTools.durationFormat(value);
                }
            },
            {
                label: '流程版本',
                prop: 'procDefVersion',
                span: 12,
                hide: true,
            },
        ]
    }
}
